<?php

namespace app\membercall\controller;

/** 控制器类引入区 **/

use app\common\controller\Smscm;

/** 模型类引入区 **/

use app\common\model\Goods;
use app\common\model\GoodsCategory;
use app\common\model\Order;
use app\common\model\Product as ProductM;

/** 核心或第三方类引入区 **/

use app\common\model\Room;
use app\common\model\VipOrder as VipOrderM;
use my\Wx;
use think\Db;
use think\Validate;

/**
 * 商品控制器
 * @package app\api\controller
 */
class Product extends Home
{
    public $noNeedLogin = [];


    /**
     *  商品分类
     **/
    public function getCateList()
    {
        $store_id = $this->store_id;
        $goodsCateGory = new GoodsCategory();
        $list = $goodsCateGory->getList($store_id);
        $this->result('获取成功', $list, 200);
    }


    /**
     *  商品列表
     **/
    public function getProductList()
    {
        $store_id = $this->store_id;
        $cate_id = $this->request->post('cate_id');
        $keyword = $this->request->post('keyword', '');
        $limit = $this->request->post('limit', 10);
        $goodsM = new Goods();
        $list = $goodsM->productList($store_id, $cate_id, $keyword, $limit);
        $this->result('获取成功', $list, 200);
    }

    /**
     *  商品详情
     **/
    public function getProductInfo()
    {
        $store_id = $this->store_id;
        $id = $this->request->post('id');
        $goodsM = new Goods();
        $list = $goodsM->productInfo($store_id, $id);
        $this->result('获取成功', $list, 200);

    }


    /**
     * 我的商品，项目列表
     */
    public function myProduct()
    {
        //$room = Room::where('id', $this->room_id)->find();
        $user_id = $this->userInfo['id'];
        $store_id = $this->store_id;
        $limit = $this->request->post('limit', '10');
        $room_id = $this->room_id;
        $VipOrderM = new VipOrderM();

        $result = $VipOrderM->orderList('2', $user_id, $store_id, '0', $limit, $room_id);
        $this->result('获取成功', $result, 200);

    }

}
